package com.dingwei.superiordiary.adapter.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.bean.BrowseHistoryBean;
import com.dingwei.superiordiary.bean.ConfirmOrderBean;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by lihao on 2018/1/8.
 */

public class ConfirmOrderAdapter extends RecyclerArrayAdapter<ConfirmOrderBean.DataBean.ProductBean> {


    public ConfirmOrderAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new ConfirmOrderHolder(parent);
    }

    class ConfirmOrderHolder extends BaseViewHolder<ConfirmOrderBean.DataBean.ProductBean> {


        @Bind(R.id.tv_name)
        TextView tvName;
        @Bind(R.id.tv_attribute)
        TextView tvAttribute;
        @Bind(R.id.tv_goods_price)
        TextView tvGoodsPrice;

        public ConfirmOrderHolder(ViewGroup parent) {
            super(parent, R.layout.item_confirm_order);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void setData(ConfirmOrderBean.DataBean.ProductBean data) {
            super.setData(data);

            tvName.setText(data.product_name);
            tvGoodsPrice.setText("￥"+data.price);
            if (data.option==null){
                tvAttribute.setText("标准规格");
            }else {
                tvAttribute.setText(data.option.label + " " +data.option.value);
            }
        }
    }
}
